package com.cheer.ba.view.adapter;

import android.app.Activity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cheer.ba.R;
import com.cheer.ba.app.App;
import com.cheer.ba.model.HotExchangeModel;
import com.cheer.ba.utils.ImageUtils;
import com.cheer.ba.utils.SystemUtils;
import com.cheer.ba.widget.myrecycleview.BaseHolder;

public class HotExchangeHolder extends BaseHolder<HotExchangeModel> {

    LinearLayout mRecycleRoot;

    //图标
    ImageView mImg;
    //描述
    TextView mTxtDesc;
    //积分
    TextView mTxtPoint;


    public HotExchangeHolder(ViewGroup parent, int resId) {
        super(parent, resId);
        mRecycleRoot = getView(R.id.id_exchange_root_view);

        mImg = getView(R.id.id_exchange_pic_img);
        mTxtDesc = getView(R.id.id_exchange_desc_txt);
        mTxtPoint = getView(R.id.id_exchange_point_txt);
    }

    @Override
    public void setData(HotExchangeModel data) {
        if (null != data) {
            ImageUtils.showCircleImg(App.getContext(), data.pic, R.drawable.ic_bg_exchange_default, R.drawable.ic_bg_exchange_default, mImg);
//            mImg.setBackgroundResource(data.drawable);
            mTxtDesc.setText(data.mPointDesc);
            mTxtPoint.setText(data.mPoint);
        }
    }

    @Override
    public void getCount(int size) {
        if (size > 0) {
            int width = SystemUtils.getScreenWidth((Activity) getContext());
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width / size, LinearLayout.LayoutParams.WRAP_CONTENT);
            mRecycleRoot.setLayoutParams(params);
        }
    }
}